-
Notifications
You must be signed in to change notification settings - Fork 2
Enhance project caching #602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Implements project caching and refresh logic to optimize data retrieval and ensure up-to-date project information. Updates various components to support these enhancements, including the `ProjectsContextProvider` and `CachingProjectDataSource`. Add revalidation logic to API endpoints to keep cached data in sync.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements a comprehensive project caching system to optimize data retrieval performance while ensuring data stays up-to-date. The changes shift from a props-based data passing approach to a context-based system with automatic refresh capabilities.
Key changes:
- Implemented client-side project caching with automatic refresh logic via API endpoints
- Added GitHub webhook integration to trigger cache invalidation and data revalidation
- Refactored components to use React Context instead of prop drilling for project data
Reviewed Changes
Copilot reviewed 11 out of 17 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| ProjectList.tsx | Converted to use React Context instead of accepting projectDataSource prop |
| PopulatedProjectList.tsx | Removed context sync logic as projects now come directly from context |
| SplitView.tsx | Removed projectDataSource prop passing to ProjectList component |
| ProjectsContextProvider.tsx | Added automatic project fetching and refresh logic with visibility change detection |
| ProjectRepository.ts | Added debug console logging for project fetching operations |
| CachingProjectDataSource.ts | Implemented cache-first strategy with new refreshProjects method |
| route.ts (projects API) | New API endpoint that calls refreshProjects to get latest data |
| route.ts (GitHub hooks) | Added project cache refresh and path revalidation on webhook events |
| route.ts (blob API) | Added revalidation and improved caching logic for blob responses |
| layout.tsx | Switched from projectRepository to projectDataSource for initial project loading |
| docker-compose.yaml | Added PostgreSQL service and app service configuration |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 10 out of 17 changed files in this pull request and generated 3 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 10 out of 17 changed files in this pull request and generated 4 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
removed revalidatePath from blob
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 10 out of 17 changed files in this pull request and generated 3 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Enhances caching mechanisms in API responses by introducing revalidation and refining cache-control headers for better performance. Adds a loading state in the ProjectsContextProvider to prevent redundant fetch calls and ensures error handling logs are more descriptive. Simplifies code style by removing semicolons and adjusts default state initialization to optimize user experience.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 10 out of 17 changed files in this pull request and generated 1 comment.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 10 out of 17 changed files in this pull request and generated 4 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Changes the HTTP method from GET to POST for the projects API fetch request. This adjustment may address API requirements or enhance compatibility with server-side logic.
while project cache is refreshed
Eliminates the `isLoadingRef` as it was no longer in use and comments out the `hasProjectChanged` function to simplify the code. Improves the project refresh mechanism by directly updating the state when new projects are fetched, removing unnecessary checks and reducing complexity. This enhances maintainability and ensures clearer logic flow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 14 out of 21 changed files in this pull request and generated 3 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Updates the `GET /api/projects` endpoint to handle a `refresh` query parameter, enabling conditional fetching of refreshed projects. Replaces the `GET /api/refreshedProjects` endpoint with a `POST` method that directly triggers a refresh operation. Adjusts the `ProjectsContextProvider` to utilize the new `POST /api/refreshedProjects` endpoint, aligning with the updated API design. Simplifies API behavior and improves clarity between fetching current vs. refreshed project data. Refactors project API endpoints for improved refresh logic Updates project-related API endpoints to simplify behavior and enhance clarity: - Deprecates the `GET /api/projects` endpoint, replacing it with a `POST /api/refreshedProjects` endpoint for triggering project refresh operations. - Modifies `ProjectsContextProvider` to utilize the new API endpoint, ensuring consistency with the updated design. - Adds a loading guard to prevent duplicate refresh requests. Improves maintainability and aligns API operations with the intended logic for fetching refreshed project data.
ulrikandersen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're getting there! 🚀
src/features/sidebar/view/internal/sidebar/projects/ProjectList.tsx
Outdated
Show resolved
Hide resolved
Consolidates project data handling by improving caching logic and removing unused API routes. Updates API endpoint paths for better consistency. Simplifies error handling and streamlines blob retrieval in the GET route. Enhances readability and reliability by refining conditional checks and eliminating redundant code.
Updates error handling to treat decode failures as missing cache instead of logging or propagating errors. This ensures robustness when decoding cached data and prevents unintended application breakdowns due to invalid cache contents.
Eliminates the unused setProjects function from the ProjectsContext to simplify the context structure and remove unnecessary code. This enhances maintainability and reduces potential confusion. Removes unused setProjects function from context Simplifies the ProjectsContext by removing the unused setProjects function. This improves maintainability, reduces potential confusion, and eliminates unnecessary code. Adds a warning log to ProjectRepository for better debugging when cached project decoding fails.
ulrikandersen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is super awesome! Let's get it on staging 🚀🚀🚀
Implements project caching and refresh logic to optimize data retrieval and ensure up-to-date project information. Updates various components to support these enhancements, including the
ProjectsContextProviderandCachingProjectDataSource.Add revalidation logic to API endpoints to keep cached data in sync.
Description
Motivation and Context
Speed up load while getting new project data automatically on hcange.
Screenshots (if appropriate):
Types of changes